<%@ page contentType="text/html; charset=iso-8859-1" language="java" %>
<%@ taglib uri="/WEB-INF/lib/struts-bean.tld" prefix="bean"%>
<%@ taglib uri="/WEB-INF/lib/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/lib/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="/WEB-INF/lib/vSys.tld" prefix="vsys"%>
<%@ taglib uri="/WEB-INF/lib/c.tld" prefix="c"%>


<script>

function insertMoviment(){
	document.movimentForm.opr.value = 'insert';
	if (confirm('<bean:message key="moviment.insert.confirmationPrompt" />')){
		document.movimentForm.submit();
	}
}
z
function clearFields(){

	document.movimentForm.opr.value = 'clearFields';
	document.movimentForm.submit();
}

function setPlate(plate){
	document.movimentForm.plate.value = plate; 
}

</script>

<div style="font-weight: bold;">
	<vsys:showErrors />
	<br/>
</div>

<html:form action="/moviment">
	<html:hidden property="opr" />
	


	<table border="0" width="100%">
		<tr>
			<td>
			<table border="0" width="100%">
				<tr>
					<td width="40%"><bean:message key="vehicle.labels.plate" />:<br />
					<html:text property="plate" /></td>
					<td width="30%"><bean:message key="moviment.labels.km" />:<br />
					<html:text property="km" /></td>
					<td width="30%"><bean:message key="moviment.labels.value" />:<br />
					<html:text property="value" /></td>
				</tr>
				<tr>
					<td colspan="3" width="100%" style="text-align:center;"><bean:message key="moviment.labels.type" />: 
					<html:select property="eventType">
						<html:options collection="eventsCollection" property="eventTypeId"
							labelProperty="eventType" />
					</html:select></td>
				</tr>
			</table>
			</td>
		</tr>
		<tr>
		 <td>
			<table width="100%">
				<tr>
					<td width="20%">
					</td>
					<td width="30%">
						<a href="javascript:insertMoviment()"><bean:message key="moviment.labels.insertButton" /></a>
					</td>
					<td width="30%">
						<a href="javascript:clearFields()"><bean:message key="moviment.labels.clearButton" /></a>
					</td>
					<td width="20%">
					</td>
				</tr>
			</table>
		 </td>
		</tr>
	</table>

</html:form>

<c:if test="${not empty requestScope.msgConfirmation}">
	<bean:write name="msgConfirmation"/>
</c:if>

<p></p>

<table width="100%" style="border: 1px solid #969696;" cellpadding="0" cellspacing="0">
	<tr style="background-color: #969696; height: 20px; font-weight: bold;">
		<td>&nbsp;</td>
		<td width="15%"><bean:message key="vehicle.labels.plate" /></td>
		<td width="10%"><bean:message key="vehicle.labels.year" /></td>
		<td width="15%"><bean:message key="vehicle.labels.value" /></td>
		<td width="10%"><bean:message key="vehicle.labels.brand" /></td>
		<td width="10%"><bean:message key="vehicle.labels.model" /></td>
		<td width="10%"><bean:message key="vehicle.labels.color" /></td>
		<td width="15%"><bean:message key="vehicle.labels.fuel" /></td>
		<td width="7%"></td>
		<td width="5%"></td>
	</tr>
	
	<logic:iterate id="vehicle" name="vehiclesCollection" >
	
	<c:if test="${color == one}">
		<c:set var="color" value="#f3f2f2" />
	</c:if>
	<c:if test="${color == two}">
		<c:set var="color" value="#e7e6e6" />
	</c:if>
		
		<tr style="background-color: ${color} height: 15px;">
			<td>&nbsp;</td>
			<td><a href="javascript:setPlate('<bean:write name="vehicle" property="plate"/>')"><bean:write name="vehicle" property="plate"/></a></td>
			<td><bean:write name="vehicle" property="year"/></td>
			<td><bean:write name="vehicle" property="value"/></td>
			<td><bean:write name="vehicle" property="model.brand.brand"/></td>
			<td><bean:write name="vehicle" property="model.model"/></td>
			<td><bean:write name="vehicle" property="color.color"/></td>
			<td><bean:write name="vehicle" property="fuel.fuel"/></td>
			<td><a href="moviment.do?opr=view&plate=<bean:write name="vehicle" property="plate"/>"><img src="resources/editar_tr.gif" border="0" alt="Editar Veiculo"/></a></td>
		</tr>
	
	</logic:iterate>

</table>

